home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp95 / freyja_t.z / freyja_t / char.c < prev    next >
C/C++ Source or Header  |  1992-04-14  |  4KB  |  232 lines

  1. /* CHAR.C -- Character-, Line-, and Screen -Oriented Commands
  2.  
  3.     Written July 1991 by Craig A. Finseth
  4.     Copyright 1991 by Craig A. Finseth
  5. */
  6.  
  7. #include "freyja.h"
  8.  
  9. static int last_col = 0;    /* last column for ^N and ^P */
  10.  
  11. /* ------------------------------------------------------------ */
  12.  
  13. /* Move backward one character. */
  14.  
  15. void
  16. CCharB()
  17.     {
  18.     BMoveBy(-uarg);
  19.     uarg = 0;
  20.     }
  21.  
  22.  
  23. /* ------------------------------------------------------------ */
  24.  
  25. /* Delete backward one character. */
  26.  
  27. void
  28. CCharBD()
  29.     {
  30.     BMarkToPoint(cwin->point);
  31.     BMoveBy(-uarg);
  32.     BRegDelete(cwin->point);
  33.     uarg = 0;
  34.     }
  35.  
  36.  
  37. /* ------------------------------------------------------------ */
  38.  
  39. /* Move forward one character. */
  40.  
  41. void
  42. CCharF()
  43.     {
  44.     BMoveBy(uarg);
  45.     uarg = 0;
  46.     }
  47.  
  48. /* ------------------------------------------------------------ */
  49.  
  50. /* Delete forward one character. */
  51.  
  52. void
  53. CCharFD()
  54.     {
  55.     BCharDelete(uarg);
  56.     uarg = 0;
  57.     }
  58.  
  59.  
  60. /* ------------------------------------------------------------ */
  61.  
  62. /* Transpose the previous two characters. */
  63.  
  64. void
  65. CCharTran()
  66.     {
  67.     int chr;
  68.  
  69.     BMoveBy(-2);
  70.     chr = BGetChar();
  71.     BCharDelete(1);
  72.     BMoveBy(1);
  73.     BInsChar(chr);
  74.     uarg = 0;
  75.     }
  76.  
  77.  
  78. /* ------------------------------------------------------------ */
  79.  
  80. /* Move to the beginning of the current line. */
  81.  
  82. void
  83. CLineA()
  84.     {
  85.     if (BSearchB(NL, SNL)) BMoveBy(1);
  86.     }
  87.  
  88.  
  89. /* ------------------------------------------------------------ */
  90.  
  91. /* Delete the entire current line. */
  92.  
  93. void
  94. CLineAED()
  95.     {
  96.     BMarkToPoint(cwin->point);
  97.     CLineA();
  98.     RKillToMark(cwin->point, BACKWARD);
  99.     SearchNLF();
  100.  
  101.         /* force append */
  102.     lastkey = key; lasttable = table;
  103.  
  104.     RKillToMark(cwin->point, FORWARD);
  105.     }
  106.  
  107.  
  108. /* ------------------------------------------------------------ */
  109.  
  110. /* Move to the previous line. */
  111.  
  112. void
  113. CLineB()
  114.     {
  115.     if (!TabIsVMove(lastkey, lasttable)) last_col = BGetCol();
  116.     while (uarg-- > 0) SearchNLB();
  117.     BMakeColB(last_col);
  118.     }
  119.  
  120.  
  121. /* ------------------------------------------------------------ */
  122.  
  123. /* Move to the end of the current line. */
  124.  
  125. void
  126. CLineE()
  127.     {
  128.     if (BSearchF(NL, SNL)) BMoveBy(-1);
  129.     }
  130.  
  131.  
  132. /* ------------------------------------------------------------ */
  133.  
  134. /* Move to the next line. */
  135.  
  136. void
  137. CLineF()
  138.     {
  139.     if (!TabIsVMove(lastkey, lasttable)) last_col = BGetCol();
  140.     while (uarg-- > 0) SearchNLF();
  141.     BMakeColB(last_col);
  142.     }
  143.  
  144.  
  145. /* ------------------------------------------------------------ */
  146.  
  147. /* Delete to the end of the current line. */
  148.  
  149. void
  150. CLineFD()
  151.     {
  152.     BMarkToPoint(cwin->point);
  153.     if (uarg > 0) {
  154.         if (!BIsEnd() && IsNL())
  155.             BMoveBy(1);
  156.         else    CLineE();
  157.         }
  158.     else    CLineA();
  159.     RKillToMark(cwin->point, uarg > 0);
  160.     }
  161.  
  162.  
  163. /* ------------------------------------------------------------ */
  164.  
  165. /* Move to the previous screen. */
  166.  
  167. void
  168. CScrnB()
  169.     {
  170.     int cnt;
  171.  
  172.     BPointToMark(cwin->sstart);
  173.     for (cnt = uarg * (DWindHeight() - VOVERLAP) - DPrefLine(); cnt > 0;
  174.          --cnt) {
  175.         SearchNLB();
  176.         }
  177.     CLineA();
  178.     }
  179.  
  180.  
  181. /* ------------------------------------------------------------ */
  182.  
  183. /* Move the other window to the previous screen. */
  184.  
  185. void
  186. CScrnBOW()
  187.     {
  188.     if (num_windows <= 1) return;
  189.     DWindSwap();
  190.     DIncrDisplay();
  191.     CScrnB();
  192.     DIncrDisplay();
  193.     DWindSwap();
  194.     }
  195.  
  196.  
  197. /* ------------------------------------------------------------ */
  198.  
  199. /* Move to the next screen. */
  200.  
  201. void
  202. CScrnF()
  203.     {
  204.     int cnt;
  205.  
  206.     DIncrDisplay();
  207.     BPointToMark(cwin->sstart);
  208.     for (cnt = uarg * (DWindHeight() - VOVERLAP) + DPrefLine(); cnt > 0;
  209.          --cnt) {
  210.         SearchNLF();
  211.         }
  212.     }
  213.  
  214.  
  215. /* ------------------------------------------------------------ */
  216.  
  217. /* Move the other window to the next screen. */
  218.  
  219. void
  220. CScrnFOW()
  221.     {
  222.     if (num_windows <= 1) return;
  223.     DWindSwap();
  224.     DIncrDisplay();
  225.     CScrnF();
  226.     DIncrDisplay();
  227.     DWindSwap();
  228.     }
  229.  
  230.  
  231. /* end of CHAR.C -- Character-, Line-, and Screen -Oriented Commands */
  232.